package com.qfedu.job;

import com.qfedu.pojo.User;
import com.qfedu.service.UserService;
import org.quartz.Job;
import org.quartz.JobExecutionContext;
import org.quartz.JobExecutionException;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.Date;
import java.util.Random;

public class MyJob  implements Job {

    @Autowired
    private UserService userService;
    //执行业务逻辑
    @Override
    public void execute(JobExecutionContext jobExecutionContext) throws JobExecutionException {
        //业务代码
        System.out.println("excute...."+new Date());
        User user = new User();
        Random random = new Random();
        user.setUserName("steel"+random.nextInt(10000));
        user.setAge(random.nextInt(130));
        user.setPassword("123");
        userService.addUser(user);
    }
}